package j04future;

import java.util.concurrent.*;

public class J1 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService es = Executors.newFixedThreadPool(1);
        //查询余额
//        Future<Integer> future = es.submit(new Callable<Integer>() {
//            @Override
//            public Integer call() throws Exception {
//                Thread.sleep(1000);
//                return 10;
//            }
//        });
        // promise
        Future<Integer> future = es.submit(()->{
            Thread.sleep(1000);
            return 100;
        });
        System.out.println(0);
        // 1，程序暂停
        // 2，返回结果
        System.out.println(future.get());//10
        System.out.println("end");
    }
}
